home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Graphics Programming (2nd Edition) / Visual Basic Graphics Programming 2nd Edition.iso / Src / Ch7 / Wipes.bas < prev   
Encoding:
BASIC Source File  |  1999-05-31  |  19.7 KB  |  714 lines

  1. Attribute VB_Name = "Wipes"
  2. Option Explicit
  3.  
  4. Private ActiveImage As Integer
  5. Private Wiping As Boolean
  6.  
  7. Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal X As Long, ByVal Y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
  8.  
  9. ' Tile the pic_old with pic_new in a spiral
  10. ' from the outside in.
  11. Public Sub TileSpiralIn(ByVal pic_new As PictureBox, ByVal pic_old As PictureBox, ByVal ms_per_frame As Long, ByVal divisions_per_side As Integer)
  12. Dim chunk_row() As Integer
  13. Dim chunk_col() As Integer
  14.  
  15.     ' Prevent more than one wipe at a time.
  16.     If Wiping Then Exit Sub
  17.     Wiping = True
  18.  
  19.     ' Place the chunk rows and columns in the
  20.     ' arrays in their correct order.
  21.     PrepareTilesForSpiralIn divisions_per_side, chunk_row, chunk_col
  22.  
  23.     ' Display the tiles.
  24.     DisplayTiles pic_new, pic_old, ms_per_frame, divisions_per_side, chunk_row, chunk_col
  25.  
  26.     Wiping = False
  27. End Sub
  28. ' Tile the pic_old with pic_new randomly.
  29. Public Sub TileRandom(ByVal pic_new As PictureBox, ByVal pic_old As PictureBox, ByVal ms_per_frame As Long, ByVal divisions_per_side As Integer)
  30. Dim chunk_row() As Integer
  31. Dim chunk_col() As Integer
  32. Dim num_chunks As Integer
  33. Dim chunk As Integer
  34. Dim i As Integer
  35. Dim j As Integer
  36. Dim tmp As Integer
  37.  
  38.     ' Prevent more than one wipe at a time.
  39.     If Wiping Then Exit Sub
  40.     Wiping = True
  41.  
  42.     ' Allocate the chunk_row and chunk_col arrays.
  43.     num_chunks = divisions_per_side * divisions_per_side
  44.     ReDim chunk_row(1 To num_chunks)
  45.     ReDim chunk_col(1 To num_chunks)
  46.  
  47.     ' Put the row and column numbers in the
  48.     ' chunk_row and chunk_col arrays.
  49.     chunk = 1
  50.     For i = 1 To divisions_per_side
  51.         For j = 1 To divisions_per_side
  52.             chunk_row(chunk) = i - 1
  53.             chunk_col(chunk) = j - 1
  54.             chunk = chunk + 1
  55.         Next j
  56.     Next i
  57.  
  58.     ' Randomize the chunks.
  59.     For i = 1 To num_chunks - 1
  60.         ' Pick a random entry between i and divisions_per_side.
  61.         j = Int((num_chunks - i + 1) * Rnd + i)
  62.  
  63.         ' Swap that entry with the one in position i.
  64.         If i <> j Then
  65.             tmp = chunk_row(i)
  66.             chunk_row(i) = chunk_row(j)
  67.             chunk_row(j) = tmp
  68.             tmp = chunk_col(i)
  69.             chunk_col(i) = chunk_col(j)
  70.             chunk_col(j) = tmp
  71.         End If
  72.     Next i
  73.  
  74.     ' Display the tiles.
  75.     DisplayTiles pic_new, pic_old, ms_per_frame, divisions_per_side, chunk_row, chunk_col
  76.  
  77.     Wiping = False
  78. End Sub
  79.  
  80. ' Tile the pic_old with pic_new in a spiral
  81. ' from the inside out.
  82. Public Sub TileSpiralOut(ByVal pic_new As PictureBox, ByVal pic_old As PictureBox, ByVal ms_per_frame As Long, ByVal divisions_per_side As Integer)
  83. Dim chunk_row_in() As Integer
  84. Dim chunk_col_in() As Integer
  85. Dim chunk_row() As Integer
  86. Dim chunk_col() As Integer
  87. Dim num_chunks As Integer
  88. Dim chunk As Integer
  89.  
  90.     ' Prevent more than one wipe at a time.
  91.     If Wiping Then Exit Sub
  92.     Wiping = True
  93.  
  94.     ' Place the chunk rows and columns in the
  95.     ' arrays in their correct order for a spiral in.
  96.     PrepareTilesForSpiralIn divisions_per_side, chunk_row_in, chunk_col_in
  97.  
  98.     ' Allocate space for the outward spiral info.
  99.     num_chunks = UBound(chunk_row_in)
  100.     ReDim chunk_row(1 To num_chunks)
  101.     ReDim chunk_col(1 To num_chunks)
  102.  
  103.     ' Reverse the tiles so they spiral out.
  104.     For chunk = 1 To num_chunks
  105.         chunk_row(chunk) = chunk_row_in(num_chunks - chunk + 1)
  106.         chunk_col(chunk) = chunk_col_in(num_chunks - chunk + 1)
  107.     Next chunk
  108.  
  109.     ' Display the tiles.
  110.     DisplayTiles pic_new, pic_old, ms_per_frame, divisions_per_side, chunk_row, chunk_col
  111.  
  112.     Wiping = False
  113. End Sub
  114.  
  115. ' Place the chunk rows and columns in the
  116. ' arrays in their correct order.
  117. Private Sub PrepareTilesForSpiralIn(ByVal divisions_per_side As Integer, ByRef chunk_row() As Integer, ByRef chunk_col() As Integer)
  118. Dim num_chunks As Integer
  119. Dim chunk As Integer
  120. Dim r As Integer
  121. Dim c As Integer
  122. Dim dr As Integer
  123. Dim dc As Integer
  124. Dim rmin As Integer
  125. Dim rmax As Integer
  126. Dim cmin As Integer
  127. Dim cmax As Integer
  128.  
  129.     ' Allocate arrays to hold the chunk rows and
  130.     ' columns in the correct order.
  131.     num_chunks = divisions_per_side * divisions_per_side
  132.     ReDim chunk_row(1 To num_chunks)
  133.     ReDim chunk_col(1 To num_chunks)
  134.  
  135.     ' Place the chunk rows and columns in the
  136.     ' arrays in their correct order.
  137.     rmin = 0
  138.     cmin = 0
  139.     rmax = divisions_per_side - 1
  140.     cmax = divisions_per_side - 1
  141.     chunk = 1
  142.     Do
  143.         ' Top.
  144.         For c = cmin To cmax
  145.             chunk_row(chunk) = rmin
  146.             chunk_col(chunk) = c
  147.             chunk = chunk + 1
  148.         Next c
  149.         If chunk > num_chunks Then Exit Do
  150.         rmin = rmin + 1
  151.  
  152.         ' Right.
  153.         For r = rmin To rmax
  154.             chunk_row(chunk) = r
  155.             chunk_col(chunk) = cmax
  156.             chunk = chunk + 1
  157.         Next r
  158.         If chunk > num_chunks Then Exit Do
  159.         cmax = cmax - 1
  160.  
  161.         ' Bottom.
  162.         For c = cmax To cmin Step -1
  163.             chunk_row(chunk) = rmax
  164.             chunk_col(chunk) = c
  165.             chunk = chunk + 1
  166.         Next c
  167.         If chunk > num_chunks Then Exit Do
  168.         rmax = rmax - 1
  169.  
  170.         ' Left.
  171.         For r = rmax To rmin Step -1
  172.             chunk_row(chunk) = r
  173.             chunk_col(chunk) = cmin
  174.             chunk = chunk + 1
  175.         Next r
  176.         If chunk > num_chunks Then Exit Do
  177.         cmin = cmin + 1
  178.     Loop
  179. End Sub
  180.  
  181. ' Display the tiles in the indicated order.
  182. Private Sub DisplayTiles(ByVal pic_new As PictureBox, ByVal pic_old As PictureBox, ByVal ms_per_frame As Long, ByVal divisions_per_side As Integer, chunk_row() As Integer, chunk_col() As Integer)
  183. Dim num_chunks As Integer
  184. Dim chunk As Integer
  185. Dim next_time As Long
  186. Dim wid As Single
  187. Dim hgt As Single
  188.  
  189.     wid = pic_old.ScaleWidth / divisions_per_side
  190.     hgt = pic_old.ScaleHeight / divisions_per_side
  191.     num_chunks = divisions_per_side * divisions_per_side
  192.  
  193.     ' Start displaying the tiles.
  194.     next_time = GetTickCount()
  195.     For chunk = 1 To num_chunks
  196.         ' Copy the tile area.
  197.         BitBlt pic_old.hDC, _
  198.             wid * chunk_col(chunk), _
  199.             hgt * chunk_row(chunk), _
  200.             wid, hgt, _
  201.             pic_new.hDC, _
  202.             wid * chunk_col(chunk), _
  203.             hgt * chunk_row(chunk), _
  204.             vbSrcCopy
  205.         pic_old.Refresh
  206.  
  207.         ' Wait for the next frame's time.
  208.         next_time = next_time + ms_per_frame
  209.         WaitTill next_time
  210.     Next chunk
  211.  
  212.     ' Finish up.
  213.     pic_old.Picture = pic_new.Picture
  214. End Sub
  215.  
  216. ' Wipe pic_new onto pic_old from the bottom up.
  217. Public Sub WipeBottomToTop(ByVal pic_new As PictureBox, ByVal pic_old As PictureBox, ByVal ms_per_frame As Long, ByVal pixels_per_frame As Integer)
  218. Dim next_time As Long
  219. Dim wid As Single
  220. Dim hgt As Single
  221. Dim Y As Single
  222.  
  223.     ' Prevent more than one wipe at a time.
  224.     If Wiping Then Exit Sub
  225.     Wiping = True
  226.  
  227.     wid = pic_old.ScaleWidth
  228.     hgt = pic_old.ScaleHeight
  229.  
  230.     ' Start moving the image.
  231.     Y = 0
  232.     next_time = GetTickCount()
  233.     Do While Y <= hgt
  234.         ' Copy the area.
  235.         BitBlt pic_old.hDC, 0, hgt - Y, wid, Y, _
  236.             pic_new.hDC, 0, hgt - Y, vbSrcCopy
  237.         pic_old.Refresh
  238.  
  239.         ' Wait for the next frame's time.
  240.         next_time = next_time + ms_per_frame
  241.         WaitTill next_time
  242.  
  243.         Y = Y + pixels_per_frame
  244.     Loop
  245.  
  246.     ' Finish up.
  247.     pic_old.Picture = pic_new.Picture
  248.     Wiping = False
  249. End Sub
  250. ' Push pic_new onto pic_old from the bottom up.
  251. Public Sub PushBottomToTop(ByVal pic_new As PictureBox, ByVal pic_old As PictureBox, ByVal ms_per_frame As Long, ByVal pixels_per_frame As Integer)
  252. Dim next_time As Long
  253. Dim wid As Single
  254. Dim hgt As Single
  255. Dim Y As Single
  256.  
  257.     ' Prevent more than one wipe at a time.
  258.     If Wiping Then Exit Sub
  259.     Wiping = True
  260.  
  261.     wid = pic_old.ScaleWidth
  262.     hgt = pic_old.ScaleHeight
  263.  
  264.     ' Start moving the image.
  265.     Y = 0
  266.     next_time = GetTickCount()
  267.     Do While Y <= hgt
  268.         ' Move the existing area.
  269.         BitBlt pic_old.hDC, 0, 0, wid, hgt - Y, _
  270.             pic_old.hDC, 0, pixels_per_frame, vbSrcCopy
  271.  
  272.         ' Copy the area.
  273.         BitBlt pic_old.hDC, 0, hgt - Y, wid, Y, _
  274.             pic_new.hDC, 0, 0, vbSrcCopy
  275.         pic_old.Refresh
  276.  
  277.         ' Wait for the next frame's time.
  278.         next_time = next_time + ms_per_frame
  279.         WaitTill next_time
  280.  
  281.         Y = Y + pixels_per_frame
  282.     Loop
  283.  
  284.     ' Finish up.
  285.     pic_old.Picture = pic_new.Picture
  286.     Wiping = False
  287. End Sub
  288. ' Push pic_new onto pic_old from the top down.
  289. Public Sub PushTopToBottom(ByVal pic_new As PictureBox, ByVal pic_old As PictureBox, ByVal ms_per_frame As Long, ByVal pixels_per_frame As Integer)
  290. Dim next_time As Long
  291. Dim wid As Single
  292. Dim hgt As Single
  293. Dim Y As Single
  294.  
  295.     ' Prevent more than one wipe at a time.
  296.     If Wiping Then Exit Sub
  297.     Wiping = True
  298.  
  299.     wid = pic_old.ScaleWidth
  300.     hgt = pic_old.ScaleHeight
  301.  
  302.     ' Start moving the image.
  303.     Y = 0
  304.     next_time = GetTickCount()
  305.     Do While Y <= hgt
  306.         ' Move the existing area.
  307.         BitBlt pic_old.hDC, 0, Y + pixels_per_frame, wid, hgt - Y, _
  308.             pic_old.hDC, 0, Y, vbSrcCopy
  309.  
  310.         ' Copy the area.
  311.         BitBlt pic_old.hDC, 0, 0, wid, Y, _
  312.             pic_new.hDC, 0, hgt - Y, vbSrcCopy
  313.         pic_old.Refresh
  314.  
  315.         ' Wait for the next frame's time.
  316.         next_time = next_time + ms_per_frame
  317.         WaitTill next_time
  318.  
  319.         Y = Y + pixels_per_frame
  320.     Loop
  321.  
  322.     ' Finish up.
  323.     pic_old.Picture = pic_new.Picture
  324.     Wiping = False
  325. End Sub
  326.  
  327.  
  328. ' Wipe pic_new onto pic_old from left to right.
  329. Public Sub WipeLeftToRight(ByVal pic_new As PictureBox, ByVal pic_old As PictureBox, ByVal ms_per_frame As Long, ByVal pixels_per_frame As Integer)
  330. Dim next_time As Long
  331. Dim wid As Single
  332. Dim hgt As Single
  333. Dim X As Single
  334.  
  335.     ' Prevent more than one wipe at a time.
  336.     If Wiping Then Exit Sub
  337.     Wiping = True
  338.  
  339.     wid = pic_old.ScaleWidth
  340.     hgt = pic_old.ScaleHeight
  341.  
  342.     ' Start moving the image.
  343.     X = 0
  344.     next_time = GetTickCount()
  345.     Do While X <= wid
  346.         ' Copy the area.
  347.         BitBlt pic_old.hDC, 0, 0, X, hgt, _
  348.             pic_new.hDC, 0, 0, vbSrcCopy
  349.         pic_old.Refresh
  350.  
  351.         ' Wait for the next frame's time.
  352.         next_time = next_time + ms_per_frame
  353.         WaitTill next_time
  354.  
  355.         X = X + pixels_per_frame
  356.     Loop
  357.  
  358.     ' Finish up.
  359.     pic_old.Picture = pic_new.Picture
  360.     Wiping = False
  361. End Sub
  362. ' Push pic_new onto pic_old from left to right.
  363. Public Sub PushLeftToRight(ByVal pic_new As PictureBox, ByVal pic_old As PictureBox, ByVal ms_per_frame As Long, ByVal pixels_per_frame As Integer)
  364. Dim next_time As Long
  365. Dim wid As Single
  366. Dim hgt As Single
  367. Dim X As Single
  368.  
  369.     ' Prevent more than one wipe at a time.
  370.     If Wiping Then Exit Sub
  371.     Wiping = True
  372.  
  373.     wid = pic_old.ScaleWidth
  374.     hgt = pic_old.ScaleHeight
  375.  
  376.     ' Start moving the image.
  377.     X = 0
  378.     next_time = GetTickCount()
  379.     Do While X <= wid
  380.         ' Move the existing area.
  381.         BitBlt pic_old.hDC, X, 0, wid - X, hgt, _
  382.             pic_old.hDC, X - pixels_per_frame, 0, vbSrcCopy
  383.  
  384.         ' Copy the area.
  385.         BitBlt pic_old.hDC, 0, 0, X, hgt, _
  386.             pic_new.hDC, wid - X, 0, vbSrcCopy
  387.         pic_old.Refresh
  388.  
  389.         ' Wait for the next frame's time.
  390.         next_time = next_time + ms_per_frame
  391.         WaitTill next_time
  392.  
  393.         X = X + pixels_per_frame
  394.     Loop
  395.  
  396.     ' Finish up.
  397.     pic_old.Picture = pic_new.Picture
  398.     Wiping = False
  399. End Sub
  400. ' Push pic_new onto pic_old from right to left.
  401. Public Sub PushRightToLeft(ByVal pic_new As PictureBox, ByVal pic_old As PictureBox, ByVal ms_per_frame As Long, ByVal pixels_per_frame As Integer)
  402. Dim next_time As Long
  403. Dim wid As Single
  404. Dim hgt As Single
  405. Dim X As Single
  406.  
  407.     ' Prevent more than one wipe at a time.
  408.     If Wiping Then Exit Sub
  409.     Wiping = True
  410.  
  411.     wid = pic_old.ScaleWidth
  412.     hgt = pic_old.ScaleHeight
  413.  
  414.     ' Start moving the image.
  415.     X = 0
  416.     next_time = GetTickCount()
  417.     Do While X <= wid
  418.         ' Move the existing area.
  419.         BitBlt pic_old.hDC, 0, 0, wid - X, hgt, _
  420.             pic_old.hDC, pixels_per_frame, 0, vbSrcCopy
  421.  
  422.         ' Copy the area.
  423.         BitBlt pic_old.hDC, wid - X, 0, X, hgt, _
  424.             pic_new.hDC, 0, 0, vbSrcCopy
  425.         pic_old.Refresh
  426.  
  427.         ' Wait for the next frame's time.
  428.         next_time = next_time + ms_per_frame
  429.         WaitTill next_time
  430.  
  431.         X = X + pixels_per_frame
  432.     Loop
  433.  
  434.     ' Finish up.
  435.     pic_old.Picture = pic_new.Picture
  436.     Wiping = False
  437. End Sub
  438.  
  439.  
  440. ' Wipe pic_new onto pic_old from right to left.
  441. Public Sub WipeRightToLeft(ByVal pic_new As PictureBox, ByVal pic_old As PictureBox, ByVal ms_per_frame As Long, ByVal pixels_per_frame As Integer)
  442. Dim next_time As Long
  443. Dim wid As Single
  444. Dim hgt As Single
  445. Dim X As Single
  446.  
  447.     ' Prevent more than one wipe at a time.
  448.     If Wiping Then Exit Sub
  449.     Wiping = True
  450.  
  451.     wid = pic_old.ScaleWidth
  452.     hgt = pic_old.ScaleHeight
  453.  
  454.     ' Start moving the image.
  455.     X = 0
  456.     next_time = GetTickCount()
  457.     Do While X <= wid
  458.         ' Copy the area.
  459.         BitBlt pic_old.hDC, wid - X, 0, X, hgt, _
  460.             pic_new.hDC, wid - X, 0, vbSrcCopy
  461.         pic_old.Refresh
  462.  
  463.         ' Wait for the next frame's time.
  464.         next_time = next_time + ms_per_frame
  465.         WaitTill next_time
  466.  
  467.         X = X + pixels_per_frame
  468.     Loop
  469.  
  470.     ' Finish up.
  471.     pic_old.Picture = pic_new.Picture
  472.     Wiping = False
  473. End Sub
  474.  
  475.  
  476. ' Wipe pic_new onto pic_old from the upper right
  477. ' to the lower left.
  478. Public Sub WipeURtoLL(ByVal pic_new As PictureBox, ByVal pic_old As PictureBox, ByVal ms_per_frame As Long, ByVal pixels_per_frame As Integer)
  479. Dim next_time As Long
  480. Dim wid As Single
  481. Dim hgt As Single
  482. Dim imax As Single
  483. Dim i As Single
  484.  
  485.     ' Prevent more than one wipe at a time.
  486.     If Wiping Then Exit Sub
  487.     Wiping = True
  488.  
  489.     wid = pic_old.ScaleWidth
  490.     hgt = pic_old.ScaleHeight
  491.     If wid > hgt Then
  492.         imax = wid
  493.     Else
  494.         imax = hgt
  495.     End If
  496.  
  497.     ' Start moving the image.
  498.     i = 0
  499.     next_time = GetTickCount()
  500.     Do While i <= imax
  501.         ' Copy the area.
  502.         BitBlt pic_old.hDC, imax - i, 0, wid, i, _
  503.             pic_new.hDC, imax - i, 0, vbSrcCopy
  504.         pic_old.Refresh
  505.  
  506.         ' Wait for the next frame's time.
  507.         next_time = next_time + ms_per_frame
  508.         WaitTill next_time
  509.  
  510.         i = i + pixels_per_frame
  511.     Loop
  512.  
  513.     ' Finish up.
  514.     pic_old.Picture = pic_new.Picture
  515.     Wiping = False
  516. End Sub
  517. ' Wipe pic_new onto pic_old from the lower right
  518. ' to the upper left.
  519. Public Sub WipeLRtoUL(ByVal pic_new As PictureBox, ByVal pic_old As PictureBox, ByVal ms_per_frame As Long, ByVal pixels_per_frame As Integer)
  520. Dim next_time As Long
  521. Dim wid As Single
  522. Dim hgt As Single
  523. Dim imax As Single
  524. Dim i As Single
  525.  
  526.     ' Prevent more than one wipe at a time.
  527.     If Wiping Then Exit Sub
  528.     Wiping = True
  529.  
  530.     wid = pic_old.ScaleWidth
  531.     hgt = pic_old.ScaleHeight
  532.     If wid > hgt Then
  533.         imax = wid
  534.     Else
  535.         imax = hgt
  536.     End If
  537.  
  538.     ' Start moving the image.
  539.     i = 0
  540.     next_time = GetTickCount()
  541.     Do While i <= imax
  542.         ' Copy the area.
  543.         BitBlt pic_old.hDC, 0, imax - i, i, i, _
  544.             pic_new.hDC, 0, imax - i, vbSrcCopy
  545.         pic_old.Refresh
  546.  
  547.         ' Wait for the next frame's time.
  548.         next_time = next_time + ms_per_frame
  549.         WaitTill next_time
  550.  
  551.         i = i + pixels_per_frame
  552.     Loop
  553.  
  554.     ' Finish up.
  555.     pic_old.Picture = pic_new.Picture
  556.     Wiping = False
  557. End Sub
  558. ' Wipe pic_new onto pic_old from the center outward.
  559. Public Sub WipeCenterOut(ByVal pic_new As PictureBox, ByVal pic_old As PictureBox, ByVal ms_per_frame As Long, ByVal pixels_per_frame As Integer)
  560. Dim next_time As Long
  561. Dim wid As Single
  562. Dim hgt As Single
  563. Dim imax As Single
  564. Dim i As Single
  565.  
  566.     ' Prevent more than one wipe at a time.
  567.     If Wiping Then Exit Sub
  568.     Wiping = True
  569.  
  570.     wid = pic_old.ScaleWidth
  571.     hgt = pic_old.ScaleHeight
  572.     If wid > hgt Then
  573.         imax = wid / 2
  574.     Else
  575.         imax = hgt / 2
  576.     End If
  577.  
  578.     ' Start moving the image.
  579.     i = 0
  580.     next_time = GetTickCount()
  581.     Do While i <= imax
  582.         ' Copy the area.
  583.         BitBlt pic_old.hDC, wid / 2 - i, hgt / 2 - i, 2 * i, 2 * i, _
  584.             pic_new.hDC, wid / 2 - i, hgt / 2 - i, vbSrcCopy
  585.         pic_old.Refresh
  586.  
  587.         ' Wait for the next frame's time.
  588.         next_time = next_time + ms_per_frame
  589.         WaitTill next_time
  590.  
  591.         i = i + pixels_per_frame / 2
  592.     Loop
  593.  
  594.     ' Finish up.
  595.     pic_old.Picture = pic_new.Picture
  596.     Wiping = False
  597. End Sub
  598. ' Wipe pic_new onto pic_old from the lower left
  599. ' to the upper right.
  600. Public Sub WipeLLtoUR(ByVal pic_new As PictureBox, ByVal pic_old As PictureBox, ByVal ms_per_frame As Long, ByVal pixels_per_frame As Integer)
  601. Dim next_time As Long
  602. Dim wid As Single
  603. Dim hgt As Single
  604. Dim imax As Single
  605. Dim i As Single
  606.  
  607.     ' Prevent more than one wipe at a time.
  608.     If Wiping Then Exit Sub
  609.     Wiping = True
  610.  
  611.     wid = pic_old.ScaleWidth
  612.     hgt = pic_old.ScaleHeight
  613.     If wid > hgt Then
  614.         imax = wid
  615.     Else
  616.         imax = hgt
  617.     End If
  618.  
  619.     ' Start moving the image.
  620.     i = 0
  621.     next_time = GetTickCount()
  622.     Do While i <= imax
  623.         ' Copy the area.
  624.         BitBlt pic_old.hDC, imax - i, imax - i, i, i, _
  625.             pic_new.hDC, imax - i, imax - i, vbSrcCopy
  626.         pic_old.Refresh
  627.  
  628.         ' Wait for the next frame's time.
  629.         next_time = next_time + ms_per_frame
  630.         WaitTill next_time
  631.  
  632.         i = i + pixels_per_frame
  633.     Loop
  634.  
  635.     ' Finish up.
  636.     pic_old.Picture = pic_new.Picture
  637.     Wiping = False
  638. End Sub
  639. ' Wipe pic_new onto pic_old from the upper left
  640. ' to the lower right.
  641. Public Sub WipeULtoLR(ByVal pic_new As PictureBox, ByVal pic_old As PictureBox, ByVal ms_per_frame As Long, ByVal pixels_per_frame As Integer)
  642. Dim next_time As Long
  643. Dim wid As Single
  644. Dim hgt As Single
  645. Dim imax As Single
  646. Dim i As Single
  647.  
  648.     ' Prevent more than one wipe at a time.
  649.     If Wiping Then Exit Sub
  650.     Wiping = True
  651.  
  652.     wid = pic_old.ScaleWidth
  653.     hgt = pic_old.ScaleHeight
  654.     If wid > hgt Then
  655.         imax = wid
  656.     Else
  657.         imax = hgt
  658.     End If
  659.  
  660.     ' Start moving the image.
  661.     i = 0
  662.     next_time = GetTickCount()
  663.     Do While i <= imax
  664.         ' Copy the area.
  665.         BitBlt pic_old.hDC, 0, 0, i, i, _
  666.             pic_new.hDC, 0, 0, vbSrcCopy
  667.         pic_old.Refresh
  668.  
  669.         ' Wait for the next frame's time.
  670.         next_time = next_time + ms_per_frame
  671.         WaitTill next_time
  672.  
  673.         i = i + pixels_per_frame
  674.     Loop
  675.  
  676.     ' Finish up.
  677.     pic_old.Picture = pic_new.Picture
  678.     Wiping = False
  679. End Sub
  680. ' Wipe pic_new onto pic_old from the top down.
  681. Public Sub WipeTopToBottom(ByVal pic_new As PictureBox, ByVal pic_old As PictureBox, ByVal ms_per_frame As Long, ByVal pixels_per_frame As Integer)
  682. Dim next_time As Long
  683. Dim wid As Single
  684. Dim hgt As Single
  685. Dim Y As Single
  686.  
  687.     ' Prevent more than one wipe at a time.
  688.     If Wiping Then Exit Sub
  689.     Wiping = True
  690.  
  691.     wid = pic_old.ScaleWidth
  692.     hgt = pic_old.ScaleHeight
  693.  
  694.     ' Start moving the image.
  695.     Y = 0
  696.     next_time = GetTickCount()
  697.     Do While Y <= hgt
  698.         ' Copy the area.
  699.         BitBlt pic_old.hDC, 0, 0, wid, Y, _
  700.             pic_new.hDC, 0, 0, vbSrcCopy
  701.         pic_old.Refresh
  702.  
  703.         ' Wait for the next frame's time.
  704.         next_time = next_time + ms_per_frame
  705.         WaitTill next_time
  706.  
  707.         Y = Y + pixels_per_frame
  708.     Loop
  709.  
  710.     ' Finish up.
  711.     pic_old.Picture = pic_new.Picture
  712.     Wiping = False
  713. End Sub
  714.